// pages/excusedInfo/excusedInfo.js
const host=getApp().host;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:{},
    list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.request({
      url: host+'/client/excused/info?id='+options.id,
      success:res=>{
        let info=res.data.data.info;
        info.date=this.formatDate(info);
        let list=res.data.data.list;
        list.forEach(item=>{
          item.date=this.formatDate(item)
        })
        this.setData({
          info:info,
          list:list
        })
      }
    })
  },

  formatDate(row){
    let date = new Date(row.date);
    let month =
          date.getMonth() + 1 < 10
                ? "0" + (date.getMonth() + 1)
                : date.getMonth() + 1;
    let day =
          date.getDate() < 10
                ? "0" + date.getDate()
                : date.getDate();
    let hours =
          date.getHours() < 10
                ? "0" + date.getHours()
                : date.getHours();
    let minutes =
          date.getMinutes() < 10
                ? "0" + date.getMinutes()
                : date.getMinutes();
    return (
          date.getFullYear() +
          "-" +
          month +
          "-" +
          day +
          " " +
          hours +
          ":" +
          minutes
    );
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
})